﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace TowerDef_s_enseLibrary.game
{
    public class Sprite
    {
        #region variables

        protected Texture2D Texture;

        protected Vector2 position;
        /// <summary>
        /// Get the position of the Sprite
        /// </summary>
        public Vector2 Position
        {
            get
            {
                return position;
            }
        }
        protected Vector2 velocity;
        protected Vector2 center;
        /// <summary>
        /// Get the center of the Sprite
        /// </summary>
        public Vector2 Center
        {
            get
            {
                return center;
            }
        }
        protected Vector2 origin;

        protected float rotation;

        #endregion variables

        #region functions

        /// <summary>
        /// Creates a sprite
        /// </summary>
        /// <param name="tex">The Texture of the sprite</param>
        /// <param name="pos">The Position of the Sprite</param>
        public Sprite(Texture2D tex, Vector2 pos)
        {
            Texture = tex;
            position = pos;
            velocity = Vector2.Zero;

            center = new Vector2(position.X + Texture.Width /  2, position.Y + Texture.Height / 2);
            origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
        }

        /// <summary>
        /// Updates the sprites in matters of the game time
        /// </summary>
        /// <param name="gameTime">The current game time</param>
        public virtual void Update(GameTime gameTime)
        {
            this.center = new Vector2(position.X + Texture.Width / 2, position.Y + Texture.Height / 2);
        }

        /// <summary>
        /// Draws the current sprites
        /// </summary>
        /// <param name="spriteBatch">A group of sprite settings</param>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, center, null, Color.White, rotation, origin, 1.0f, SpriteEffects.None, 0);
        }
        /// <summary>
        /// Draws the current sprites
        /// </summary>
        /// <param name="spriteBatch">A group of sprite settings</param>
        /// <param name="color">The color of the sprite</param>
        public virtual void Draw(SpriteBatch spriteBatch, Color color)
        {
            spriteBatch.Draw(Texture, center, null, color, rotation, origin, 1.0f, SpriteEffects.None, 0);
        }

        #endregion functions

        #region events



        #endregion events
    }
}
